<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script>
	const arr = [35,2,26,2,6,78,45,62,4,18,26,37,9,33,123]
	function radixSort(arr) {
		let base = 10
		let divider = 1
		const maxVal = Math.max(...arr)
		while(divider <= maxVal) {
			// 构建二维数组,	分别给每个数位 (0到9) 创造一个桶(数列), 共计10个遍历每个数位
			const buckets = [...Array(10)].map(() => [])
			for (const val of arr) {
				// 将元素按个位数,10位数这样比较放到相应的桶
				buckets[Math.floor((val / divider) % base)].push(val)
			}
			console.log('buckets', buckets);
			arr = [].concat(...buckets)
			console.log('arr', arr);
			divider*= 10
		}
	}
	radixSort(arr)
	</script>	
</body>
</html>